<%@page import="com.bringway.global.util.UserUtil"%>
<%@page import="com.bringway.p2p.constant.P2pConstant"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	String baseUrl = request.getContextPath();
	request.setAttribute("baseUrl", baseUrl);
	if(null !=  UserUtil.getCurrentUser()){
		response.sendRedirect(baseUrl + "/pages/main/main.jsp");		
	}
%>
<!DOCTYPE html>
<html>
<head>
<link rel="Shortcut Icon" href="${baseUrl}/global/images/favicon.ico" />
<link rel="Bookmark" href="${baseUrl}/global/images/favicon.ico" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><%=P2pConstant.WebsiteName %>管理系统</title>
<style type="text/css">
<!--
body, td, th {
	font-family: 微软雅黑;
	font-size: 12px;
	color: #333333;
}

body {
	margin: 0 auto;
	background-image: url(global/images/loginbg.jpg);
	background-repeat: no-repeat;
	background-position: center top;
	background-color: #F2F2F2;
	width: 1000px;
}

a:link {
	color: #333333;
	text-decoration: none;
}

a:visited {
	text-decoration: none;
	color: #333333;
}

a:hover {
	text-decoration: none;
	color: #01A2AA;
}

a:active {
	text-decoration: none;
	color: #01A2AA;
}

.login2016 {
	width: auto;
	height: 455px;
	padding-top: 305px;
	padding-left: 678px;
	padding-right: 48px;
}

#logtab td {
	height: auto;
}

#logtab td .error {
	height: 30px;
	margin: 2px 0;
	line-height: 30px;
	color: #FF0000;
	padding-left: 38px;
}

#logtab input {
	width: 224px;
	height: 38px;
	line-height: 38px;
	background-color: #FFFFFF;
	padding-left: 50px;
	border: 0px #fff solid;
	color: #666666;
	font-size: 14px;
	border-radius: 3px;
}

#logtab .input1 {
	background-image: url(global/images/login_3.jpg);
	background-repeat: no-repeat;
	background-position: left center;
}

#logtab .input2 {
	background-image: url(global/images/login_6.jpg);
	background-repeat: no-repeat;
	background-position: left center;
}

.bottom2016 {
	width: 1000px;
	height: 105px;
	padding-top: 35px;
	line-height: 35px;
	text-align: center;
	color: #878787;
}

.bottom2016 a {
	color: #878787 !important;
}

#logtab .input3 {
	background: #f0801d;
	border: 0;
	padding: 10px 0;
	text-align: center;
	font-size: 14px;
	font-weight: normal;
	width: 100%;
	text-transform: uppercase;
	-moz-border-radius: 2px;
	-webkit-border-radius: 2px;
	border-radius: 2px;
	-moz-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
	-webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
	color: #fff;
	height: 40px;
}

#logtab .input3:hover {
	background-color: #f0721e;
}
-->
</style>
<script type="text/javascript" src="framework/jquery/jquery.js"></script>
<script type="text/javascript" src="framework/jquery/script.js"></script>
<script type="text/javascript">
	var baseUrl = '<%=baseUrl%>';
</script>
</head>

<body>

	<div class="login2016">
		<form id="new_user_session" name="form1"
			action="<%=baseUrl%>/j_spring_security_check"
			onSubmit="return submitTest();" novalidate="novalidate"
			class="simple_form user" accept-charset="UTF-8" data-remote="true"
			method="post">
			<table width="100%" border="0" cellspacing="0" cellpadding="0"
				id="logtab">
				<tr>
					<td><input type="text" name="j_username" id="j_username"
						class="input1" />
						<p class="error" id="error1"></p></td>
				</tr>
				<tr>
					<td><input type="password" name="j_password" id="j_password"
						class="input2" />
						<p class="error" id="error2"></p></td>
				</tr>
				<tr>
					<td><button type="submit" id="loginBtn" class="input3">登录</button></td>
				</tr>
			</table>
		</form>
	</div>

	<div class="bottom2016">
		<br /> Copyright © 2016 <%=P2pConstant.CopyrightCompanyName%> 服务电话：<%=P2pConstant.CompanyPhone %>
	</div>
	<script>
		$(document).keydown(function(e) {
			if (e.keyCode == 13) {
				submitTest();
			}
		});

		function submitTest() {
			var j_username = $("#j_username").val();
			var j_password = $("#j_password").val();

			if (j_username == '') {
				$("#error1").html("工号不能为空！");
				return false;
			} else {
				$("#error1").html("");
			}
			if (j_password == '') {
				$("#error2").html("密码不能为空！");
				return false;
			} else {
				$("#error2").html("");
			}
			if (!j_username == '' && !j_password == '') {
				var ckh_result = false;
				var params = $("#new_user_session").serialize();
				console.log(params);
				$.post(baseUrl + "/p2puser/p2pLogin.do", {
					j_username : j_username,
					j_password : j_password
				}, function(data, status) {
					if (data.data.msg == "登陆成功！") {
						document.form1.submit();
						ckh_result = true;
					} else {
						if (data.data.msg == "用户名输入错误！") {
							$("#error1").html("请输入正确的工号！");
							ckh_result = false;
						}
						if (data.data.msg == "密码错误！") {
							$("#error2 ").html("请输入正确的密码！");
							ckh_result = false;
						} else {
							ckh_result = false;
						}
					}
				}, "json");
				return ckh_result;
			}
		}
	</script>
</body>
</html>
